package compositepattern;

/**
 * @author Jonny Long
 * @date 2021/6/3 8:59
 */
public class Client {
    public static void main(String[] args) {
        Department node1 = new Department("北京公司总部");
        Department node2 = new Department("人力资源部");
        Department node3 = new Department("上海华东分公司");
        Department node4 = new Department("财务部");
        Department node5 = new Department("南京办事处");
        Department node6 = new Department("杭州办事处");
        // 构建树
        node1.add(node2);
        node1.add(node3);
        node1.add(node4);
        node3.add(node5);
        node3.add(node2);
        node3.add(node4);
        node3.add(node6);
        node5.add(node2);
        node5.add(node4);
        node6.add(node2);
        node6.add(node4);
        node1.print(0);
        // 构建责任链
        node5.setSuccessor(node3);
        node6.setSuccessor(node3);
        node3.setSuccessor(node1);
        // 设置加薪边界
        node5.setBound(0,1000);
        node6.setBound(0,1000);
        node3.setBound(1000,2000);
        node1.setBound(2000,3000);
        // 请求加薪
        System.out.println("**********************");
        node5.handlerRequest(500);
        System.out.println("**********************");
        node5.handlerRequest(1500);
        System.out.println("**********************");
        node5.handlerRequest(2500);
        System.out.println("**********************");
        node5.handlerRequest(3500);
    }
}
